home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / MISC / VIDEO.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-11-15  |  18.6 KB  |  767 lines

  1. ;*********************
  2. ;* FLamoot VGA SetUp *
  3. ;*********************
  4. ;(C) Type One 1994 - TFL/TDV Prod.
  5. ; email: llardin@is2.vub.ac.Be
  6.  
  7. ;-----------------------------------------
  8. ; Déclaration modèle mémoire
  9. .386
  10. DGROUP GROUP _DATA,_BSS
  11. _TEXT  SEGMENT DWORD PUBLIC USE16 'CODE'
  12.        ASSUME CS:_TEXT,DS:DGROUP
  13. _TEXT  ENDS
  14. _DATA  SEGMENT DWORD PUBLIC USE16 'DATA'
  15. _DATA  ENDS
  16. _BSS   SEGMENT DWORD PUBLIC USE16 'BSS'
  17. _BSS   ENDS
  18. ;-----------------------------------------
  19.  
  20.  
  21. _DATA  SEGMENT
  22.  
  23. ;*** GFX-mode structure *** 
  24. mode RECORD hgh:5, ver:3, hor:3, col:2, adr:2
  25. ;
  26. ; rem:   hgh = line doubling factor
  27. ;        ver = 0 --> 350 lines display     hor = 0 --> 128 horiz width
  28. ;              1     400 big                     1     160 (7-mode)
  29. ;              2     400                         2     180 (7-mode like)
  30. ;              3     400 60hz                    3     256
  31. ;              4     448                         4     320
  32. ;              5     480                         5     360
  33. ;              6     512                         
  34. ;              7     540
  35. ;        col = 0 --> 256 colors display    adr = 0 --> planar scheme (X-mode)
  36. ;              1     16                          1 --> chained
  37. ;              2     4                           2 --> cga
  38. ;              3     text 16                     3 --> mono
  39. ;
  40. ; PS: if you choose a 16 colors display, the horiz width is doubled !!!!!
  41.  
  42. ;****** VGA vertical timings ******
  43.  
  44. ;--- settings for 350 lines ---
  45. vert350 LABEL BYTE
  46.  DB 0a0h   ; vertical clock (3c2h)
  47.  DW 0bf06h ; vertical total
  48.  DW 01f07h ; overflow reg.
  49.  DW 08310h ; vertical retrace start
  50.  DW 08511h ; vertical retrace end
  51.  DW 05d12h ; vert. disp. enable end
  52.  DW 06315h ; vertical blank start
  53.  DW 0ba16h ; vertical blank end
  54.  
  55. ;--- settings for 400 lines / full scan ---
  56. vert400b LABEL BYTE
  57.  DB 0a0h   ; vertical clock (3c2h)
  58.  DW 0bf06h ; vertical total
  59.  DW 01f07h ; overflow reg.
  60.  DW 09c10h ; vertical retrace start
  61.  DW 08e11h ; vertical retrace end
  62.  DW 08f12h ; vert. disp. enable end
  63.  DW 09615h ; vertical blank start
  64.  DW 0b916h ; vertical blank end
  65.  
  66. ;--- settings for 400 lines ---
  67. vert400 LABEL BYTE
  68.  DB 060h   ; vertical clock (3c2h)
  69.  DW 0bf06h ; vertical total
  70.  DW 01f07h ; overflow reg.
  71.  DW 09c10h ; vertical retrace start
  72.  DW 08e11h ; vertical retrace end
  73.  DW 08f12h ; vert. disp. enable end
  74.  DW 09615h ; vertical blank start
  75.  DW 0b916h ; vertical blank end
  76.  
  77. ;--- settings for 400 lines / 60hz ---
  78. vert400h LABEL BYTE
  79.  DB 0e0h   ; vertical clock (3c2h)
  80.  DW 0bf06h ; vertical total
  81.  DW 01f07h ; overflow reg.
  82.  DW 09c10h ; vertical retrace start
  83.  DW 08e11h ; vertical retrace end
  84.  DW 08f12h ; vert. disp. enable end
  85.  DW 09615h ; vertical blank start
  86.  DW 0b916h ; vertical blank end
  87.  
  88. ;--- settings for 448 lines ---
  89. vert448 LABEL BYTE
  90.  DB 0e0h   ; vertical clock (3c2h)
  91.  DW 00b06h ; vertical total
  92.  DW 03e07h ; overflow reg.
  93.  DW 0da10h ; vertical retrace start
  94.  DW 09c11h ; vertical retrace end
  95.  DW 0bf12h ; vert. disp. enable end
  96.  DW 0c715h ; vertical blank start
  97.  DW 00416h ; vertical blank end
  98.  
  99. ;--- settings for 480 lines ---
  100. vert480 LABEL BYTE
  101.  DB 0e0h   ; vertical clock (3c2h)
  102.  DW 00b06h ; vertical total
  103.  DW 03e07h ; overflow reg.
  104.  DW 0ea10h ; vertical retrace start
  105.  DW 08c11h ; vertical retrace end
  106.  DW 0df12h ; vert. disp. enable end
  107.  DW 0e715h ; vertical blank start
  108.  DW 00416h ; vertical blank end
  109.  
  110. ;--- settings for 512 lines ---
  111. vert512 LABEL BYTE
  112.  DB 0e0h   ; vertical clock (3c2h)
  113.  DW 02306h ; vertical total
  114.  DW 0b207h ; overflow reg.
  115.  DW 00a10h ; vertical retrace start
  116.  DW 0ac11h ; vertical retrace end
  117.  DW 0ff12h ; vert. disp. enable end
  118.  DW 00715h ; vertical blank start
  119.  DW 01a16h ; vertical blank end
  120.  
  121. ;--- settings for 540 lines ---
  122. vert540 LABEL BYTE
  123.  DB 0e0h   ; vertical clock (3c2h)
  124.  DW 03006h ; vertical total
  125.  DW 0f007h ; overflow reg.
  126.  DW 02010h ; vertical retrace start
  127.  DW 0a911h ; vertical retrace end
  128.  DW 01b12h ; vert. disp. enable end
  129.  DW 01f15h ; vertical blank start
  130.  DW 02f16h ; vertical blank end
  131.  
  132. ;****** VGA horizontal timings ******
  133.  
  134. ;--- settings for 128 pixels ---
  135. horiz128 LABEL BYTE
  136.  DB 03h    ; horizontal clock
  137.  DW 02d00h ; horiz. total
  138.  DW 01f01h ; horiz. disp. enable end
  139.  DW 02002h ; horiz. blank start
  140.  DW 09003h ; horiz. blank end
  141.  DW 02504h ; horiz. retrace start
  142.  DW 08d05h ; horiz. retrace end
  143.  DW 01013h ; offset/logical width
  144.  DW 00801h ; clock mode register (3c4h) (00901h)
  145.  
  146. ;--- settings for 160 pixels ---
  147. horiz160 LABEL BYTE
  148.  DB 03h    ; horizontal clock
  149.  DW 02d00h ; horiz. total
  150.  DW 02701h ; horiz. disp. enable end
  151.  DW 02802h ; horiz. blank start
  152.  DW 09003h ; horiz. blank end
  153.  DW 02b04h ; horiz. retrace start
  154.  DW 08005h ; horiz. retrace start
  155.  DW 01413h ; offset/logical width
  156.  DW 00801h ; clock mode register (3c4h) (00901h)
  157.  
  158. ;--- settings for 180 pixels ---
  159. horiz180 LABEL BYTE
  160.  DB 07h    ; horiz. clock (3c2h)
  161.  DW 03200h ; horiz. total
  162.  DW 02c01h ; horiz. disp. enable end
  163.  DW 02d02h ; horiz. blank start
  164.  DW 0b003h ; horiz. blank end
  165.  DW 02f04h ; horiz. retrace start
  166.  DW 0b405h ; horiz. retrace end
  167.  DW 01713h ; offset/logical width
  168.  DW 00801h ; clock mode register (3c4h) (00901h) 
  169.  
  170. ;--- settings for 256 pixels ---
  171. horiz256 LABEL BYTE
  172.  DB 03h    ; horizontal clock
  173.  DW 05f00h ; horiz. total
  174.  DW 03f01h ; horiz. disp. enable end
  175.  DW 04002h ; horiz. blank start
  176.  DW 08203h ; horiz. blank end
  177.  DW 04a04h ; horiz. retrace start
  178.  DW 09a05h ; horiz. retrace end
  179.  DW 02013h ; offset/logical width
  180.  DW 00001h ; clock register (3c4h) (00101h)
  181.  
  182. ;--- settings for 320 pixels ---
  183. horiz320 LABEL BYTE
  184.  DB 03h    ; horizontal clock
  185.  DW 05f00h ; horiz. total
  186.  DW 04f01h ; horiz. disp. enable end
  187.  DW 05002h ; horiz. blank start
  188.  DW 08203h ; horiz. blank end
  189.  DW 05404h ; horiz. retrace start
  190.  DW 08005h ; horiz. retrace end
  191.  DW 02813h ; offset/logical width
  192.  DW 00001h ; clock register (3c4h) (00101h)
  193.  
  194. ;--- settings for 360 pixels ---
  195. horiz360 LABEL BYTE
  196.  DB 07h    ; horizontal clock
  197.  DW 06b00h ; horiz. total
  198.  DW 05901h ; horiz. disp. enable end
  199.  DW 05a02h ; horiz. blank start
  200.  DW 08e03h ; horiz. blank end
  201.  DW 05e04h ; horiz. retrace start
  202.  DW 08a05h ; horiz. retrace end
  203.  DW 02d13h ; offset/logical width
  204.  DW 00001h ; clock register (3c4h) (00101h)
  205.  
  206. ;***** Settings for colors *****
  207. EVEN
  208. col256 LABEL BYTE
  209.  DW 04005h    ; mode register (3ceh)
  210.  DB 030h,061h ; mode control  (3c0h) 
  211.  
  212. col16 LABEL BYTE
  213.  DW 00005h    ; mode register (3ceh)
  214.  DB 030h,021h ; mode control  (3c0h)
  215.  
  216. col4 LABEL BYTE
  217.  DW 03005h    ; mode register (3ceh)
  218.  DB 030h,021h ; mode control  (3c0h)
  219.  
  220. text16 LABEL BYTE
  221.  DW 01005h    ; mode register (3ceh)
  222.  DB 030h,02ch ; mode control  (3c0h)
  223.  
  224. ;***** Adressing mode *****
  225. EVEN
  226. planar LABEL WORD
  227.  DW 00604h    ; unchain (3c4h)
  228.  DW 00014h    ; turn off dword mode
  229.  DW 0e317h    ; turn on byte mode
  230.  
  231. chained LABEL WORD
  232.  DW 00e04h    ; chain   (3c4h)
  233.  DW 04014h    ; turn on dword mode
  234.  DW 0a317h    ; turn off byte mode
  235.  
  236. cga LABEL WORD
  237.  DW 00204h    ;         (3c4h)
  238.  DW 00014h
  239.  DW 0a217h
  240.  
  241. herc LABEL WORD
  242.  DW 00604h    ;         (3c4h)  
  243.  DW 00014h
  244.  DW 0c217h
  245.  
  246. ;*** Tables ***
  247. Vertab LABEL WORD
  248.  DW OFFSET vert350, OFFSET vert400b, OFFSET vert400, OFFSET vert400h
  249.  DW OFFSET vert448, OFFSET vert480, OFFSET vert512, OFFSET vert540
  250. Hortab LABEL WORD
  251.  DW OFFSET horiz128, OFFSET horiz160, OFFSET horiz180, OFFSET horiz256
  252.  DW OFFSET horiz320, OFFSET horiz360
  253. Coltab LABEL WORD
  254.  DW OFFSET col256, OFFSET col16, OFFSET col4, OFFSET text16
  255. Adrtab LABEL WORD
  256.  DW OFFSET planar, OFFSET chained, OFFSET cga, OFFSET herc
  257.  
  258. PUBLIC _BlackPal
  259. PUBLIC _WhitePal
  260.  
  261. _BlackPal DB 768 DUP(0)
  262. _WhitePal DB 768 DUP(63)
  263.  
  264. _DATA  ENDS
  265.  
  266. _BSS SEGMENT
  267. PUBLIC _TmpPal
  268.  
  269. _TmpPal DB 768 DUP(?)   ; palette buffer !!!!
  270.  
  271. _BSS ENDS
  272.  
  273. ;-----------------------------------------
  274. _TEXT SEGMENT
  275.              PUBLIC _WaitVBL
  276.              PUBLIC _WaitHBL
  277.              PUBLIC _SetVGA
  278.              PUBLIC _AveragePAL
  279. ;             PUBLIC _FadeIn
  280. ;             PUBLIC _FadeOut
  281. ;             PUBLIC _InFade
  282. ;             PUBLIC _OutFade
  283.  
  284. VSYNC MACRO          ; Om de VBL te wachten...
  285.       call _WaitVbl
  286.       ENDM
  287.  
  288. MPUSH   MACRO reg1:REQ,reg2:VARARG   ; Vive Y.Roggeman/Greg & ses Macros
  289.         push reg1                    ; recursives !!!!!!! yahouuuuu !!!
  290.         IFNB <reg2>
  291.         MPUSH reg2
  292.         ENDIF
  293.         ENDM
  294.  
  295. MPOP    MACRO reg1:REQ,reg2:VARARG   ; bis bis !!!
  296.         IFNB <reg2>                  ; type brol = record....
  297.         MPOP reg2                    ; donc ça fait 20 bytes !!!
  298.         ENDIF                        ; donc 1 word ....
  299.         pop reg1                     ; brol je dis struct !!!
  300.         ENDM
  301.  
  302.  
  303. ;*************************
  304. ;* Set Up VGA video mode *
  305. ;*************************
  306.  
  307. ALIGN
  308. EVEN
  309. _SetVGA PROC FAR
  310.  
  311.         push bp
  312.         mov  bp,sp
  313.  
  314.         MPUSH eax,bx,cx,dx,si,di,ds,es
  315.         mov   ax,DGROUP
  316.         mov   ds,ax
  317.  
  318. ;        mov  ax,13h                 ; let the BIOS start with
  319. ;        int  10h                    ; mode 13 : 320x200x256 chained 
  320.         VSYNC 
  321.  
  322.         mov  ax,WORD PTR ss:[bp+6]  ; take WORD param
  323.         cld
  324.  
  325.      ; Addressing mode
  326.         mov  bx,ax
  327.         push ax
  328.         and  bx,MASK adr            ; get adressing mode
  329.         shl  bx,1
  330.         mov  si,WORD PTR[Adrtab+bx] ; corresponding table
  331.         mov  dx,3c4h
  332.         lodsw           ; (1)         
  333.         mov  bl,ah                  ; chain/unchain (only 4 bits used)
  334.         out  dx,al
  335.         inc  dl
  336.         in   al,dx
  337.         and  al,0f0h   
  338.         and  bl,00fh
  339.         or   al,bl
  340.         out  dx,al
  341.         dec  dl
  342.         mov  dl,0d4h
  343.         lodsw           ; (2)    
  344.         mov  bl,ah                  ; dword mode on/off
  345.         out  dx,al
  346.         inc  dl
  347.         in   al,dx
  348.         and  al,080h
  349.         and  bl,060h    ; bits 5,6
  350.         or   al,bl
  351.         out  dx,al
  352.         dec  dl
  353.         outsw           ; (3)         byte mode on/off
  354.         pop  ax
  355.  
  356.      ; Color mode
  357.         mov  bx,ax
  358.         push ax
  359.         and  bx,MASK col            ; get color mode
  360.         shr  bx,col-1            
  361.         mov  si,WORD PTR[Coltab+bx] ; corresponding table       
  362.         mov  dl,0ceh
  363.         lodsw           ; (1)         display plane output
  364.         mov  bl,ah
  365.         out  dx,al
  366.         inc  dl
  367.         in   al,dx
  368.         and  al,08fh    ; bits 4,5,6   
  369.         or   al,bl
  370.         out  dx,al
  371.         dec  dl
  372.         mov  dl,0c0h
  373.         outsb           ; (2)         pixel panning compatibility + PCS
  374.         lodsb
  375.         mov  bl,al    
  376.         inc  dl      
  377.         in   al,dx
  378.         dec  dl
  379.         and  al,090h    ; bits 6,5,3,2,1,0
  380.         or   al,bl
  381.         out  dx,al
  382.         pop  ax   
  383.  
  384.       ; Modify CRTC registers
  385.         push ax 
  386.         mov  dl,0d4h
  387.         mov  al,11h                 ; cr11
  388.         out  dx,al                  ; current value
  389.         inc  dl                     ; point to data
  390.         in   al,dx                  ; get cr11 value
  391.         and  al,07fh                ; remove cr0-cr7
  392.         out  dx,al                  ; write protect
  393.         pop  ax 
  394.  
  395.       ; Horizontal parameters
  396.         mov  bx,ax
  397.         push ax
  398.         and  bx,MASK hor            ; get horizontal parameters
  399.         shr  bx,hor-1
  400.         mov  si,WORD PTR[Hortab+bx] ; corresponding table
  401.         mov  bl,BYTE PTR[si]        ; get horizontal clock
  402.         inc  si
  403.         mov  dl,0d4h
  404.         mov  cx,7
  405.         rep  outsw
  406.         mov  dl,0c4h
  407.         lodsw                       ; just OR the right bits
  408.         mov  bh,ah                  ; (clock doubling)
  409.         out  dx,al
  410.         inc  dl
  411.         in   al,dx
  412.         and  al,037h
  413.         or   al,bh
  414.         out  dx,al
  415.         pop  ax
  416.  
  417.       ; Vertical parameters
  418.         push ax
  419.         mov  cl,bl
  420.         mov  bx,ax
  421.         and  bx,MASK ver            ; get vertical parameters
  422.         shr  bx,ver-1
  423.         mov  si,WORD PTR[Vertab+bx] ; corresponding table
  424.         or   cl,BYTE PTR[si]        ; get vertical clock
  425.         inc  si         
  426.         mov  dl,0c4h                ; alter sequencer register
  427.         mov  ax,0100h               ; synchronous reset
  428.         out  dx,ax
  429.         mov  dl,0cch
  430.         in   al,dx                  ; read clock
  431.         and  al,033h
  432.         or   al,cl
  433.         mov  dl,0c2h
  434.         out  dx,al                  ; new clock
  435.         mov  dl,0c4h                ; sequencer again
  436.         mov  ax,0300h               ; restart sequencer
  437.         out  dx,ax                  ; running again
  438.         mov  dl,0d4h
  439.         outsw
  440.         outsw
  441.         outsw
  442.         lodsw      ; (1) VR End : bits 7,6,3,2,1,0
  443.         mov  cl,ah
  444.         out  dx,al
  445.         inc  dl
  446.         in   al,dx
  447.         and  al,030h
  448.         and  cl,0cfh
  449.         or   al,cl
  450.         out  dx,al
  451.         dec  dl  
  452.         outsw
  453.         outsw
  454.         lodsw      ; (3) End VBlank : bits 6,5,4,3,2,1,0
  455.         mov  cl,ah
  456.         out  dx,al
  457.         inc  dl
  458.         in   al,dx
  459.         and  al,07fh
  460.         or   al,cl
  461.         out  dx,al
  462.         pop  ax
  463.          
  464.       ; Line doubling
  465.         and  ax,MASK hgh
  466.         shr  ax,hgh                 ; cell height
  467.         mov  cl,al
  468.         mov  dl,0d4h
  469.         mov  al,009h
  470.         out  dx,al
  471.         inc  dl
  472.         in   al,dx
  473.         and  al,0e0h
  474.         or   al,cl
  475.         out  dx,al
  476.  
  477.         mov  dl,0c4h                ; Clear Vidmem
  478.         mov  ax,0f02h
  479.         out  dx,ax
  480.         mov  cx,16384
  481.         mov  ax,0a000h
  482.         mov  es,ax
  483.         xor  di,di
  484.         xor  eax,eax
  485.         rep  stosd
  486.          
  487.  
  488.         MPOP eax,bx,cx,dx,si,di,ds,es 
  489.  
  490.         leave
  491.         retf
  492.  
  493. _SetVGA ENDP
  494.  
  495. ;*************************
  496. ;* Wait Vertical Retrace *
  497. ;*************************
  498. ALIGN
  499. EVEN
  500. _WaitVBL PROC FAR
  501.  
  502.          MPUSH ax,dx
  503.  
  504.          mov  dx,3dah  ; Status Register
  505. EVEN
  506. @@:      in   al,dx
  507.          test al,08    ; bit 3
  508.          jnz  @B
  509. EVEN
  510. @@:      in   al,dx
  511.          test al,08
  512.          jz   @B
  513.  
  514.          MPOP ax,dx
  515.  
  516.          retf
  517.  
  518. _WaitVBL ENDP
  519.  
  520. ;***************************
  521. ;* Wait Horizontal Retrace *
  522. ;***************************
  523. ALIGN
  524. EVEN
  525. _WaitHBL PROC FAR
  526.  
  527.          MPUSH ax,dx
  528.  
  529.          mov  dx,3dah  ; Status Register
  530. EVEN
  531. @@:      in   al,dx
  532.          test al,01    ; bit 0
  533.          jnz  @B
  534. EVEN
  535. @@:      in   al,dx
  536.          test al,01
  537.          jz   @B
  538.  
  539.          MPOP ax,dx
  540.  
  541.          retf
  542.  
  543. _WaitHBL ENDP
  544.  
  545. ALIGN
  546. EVEN
  547.  
  548. _AveragePAL PROC FAR    ; Average 2 palets 
  549.          
  550. ; ss:[BP+6] = OFFSET Pal1
  551. ; ss:[BP+8] = SEG Pal1
  552. ; ss:[BP+10] = OFFSET Pal2
  553. ; ss:[BP+12] = SEG Pal2
  554. ; ss:[BP+14] = OFFSET Dest
  555. ; ss:[BP+16] = SEG Dest
  556. ; ss:[BP+18] = factor
  557.  
  558.          push bp
  559.          mov  bp,sp
  560.          
  561.          pusha
  562.          MPUSH ds,es,fs
  563.  
  564.          mov  ax,ss:[BP+8]
  565.          mov  ds,ax
  566.          mov  ax,ss:[BP+16]
  567.          mov  es,ax
  568.          mov  ax,ss:[BP+12]
  569.          mov  fs,ax
  570.  
  571.          mov  si,ss:[BP+6]
  572.          mov  di,ss:[BP+14]
  573.          mov  bx,ss:[BP+10]   
  574.          
  575.          mov  dl,255
  576.          sub  dl,BYTE PTR ss:[BP+18]
  577.  
  578.          mov   cl,BYTE PTR ss:[BP+18]
  579.          mov   ch,cl
  580.          not   ch
  581.  
  582.          INDICE = 0
  583.  
  584.          REPT 768                    
  585.  
  586.          lodsb                        ; (a*col1+(256-a)*col2)/256
  587.          mul  cl                      ; a
  588.          mov  dx,ax
  589.          mov  al,BYTE PTR fs:[bx+INDICE]
  590.          mul  ch                      ; 255 -a
  591.          add  ax,dx
  592.          mov  al,ah
  593.          stosb  
  594.  
  595.          INDICE = INDICE + 1
  596.  
  597.          ENDM
  598.  
  599.          MPOP ds,es,fs 
  600.          popa        
  601.  
  602.          leave
  603.          retf
  604.  
  605. _AveragePAL ENDP
  606.  
  607.  
  608. COMMENT^
  609.  
  610. ALIGN
  611. EVEN
  612. _FadeIn PROC FAR                     ; Black to Pal
  613.  
  614. ; ss:[BP+6] = OFFSET Pal
  615. ; ss:[BP+8] = SEG Pal
  616. ; ss:[BP+10] = OFFSET Dest           ; supposed to be clear at the beginning !!
  617. ; ss:[BP+12] = SEG Dest
  618.  
  619.  
  620.         push bp
  621.         mov  bp,sp
  622.  
  623.         MPUSH cx,si,di,ds,es         ; don't save AX --> result
  624.  
  625.         mov   ax,ss:[BP+8]
  626.         mov   ds,ax
  627.         mov   ax,ss:[BP+12]
  628.         mov   es,ax
  629.  
  630.         mov   si,ss:[BP+6]
  631.         mov   di,ss:[BP+10]
  632.         mov   ah,1                   ; true by default
  633.  
  634.         mov   cx,768
  635. @@:     lodsb
  636.         cmp   al,BYTE PTR es:[di]    ; have we reach the col ???
  637.         jbe   huhu
  638.         inc   BYTE PTR es:[di]
  639.         xor   ah,ah                  ; false !!!
  640. huhu:   inc   di
  641.         dec   cx
  642.         jnz   @B
  643.         xor   al,al
  644.  
  645.         MPOP  cx,si,di,ds,es
  646.  
  647.         leave
  648.         retf
  649.  
  650. _FadeIn ENDP
  651.  
  652. ALIGN
  653. EVEN
  654. _FadeOut PROC FAR                     ; Pal to Black
  655.  
  656. ; ss:[BP+6] = OFFSET Pal
  657. ; ss:[BP+8] = SEG Pal
  658.  
  659.         push bp
  660.         mov  bp,sp
  661.  
  662.         MPUSH cx,si,ds               ; AX = result !!!
  663.  
  664.         mov   ax,ss:[BP+8]
  665.         mov   ds,ax
  666.  
  667.         mov   si,ss:[BP+6]
  668.         mov   ax,1                   ; true by default
  669.  
  670.         mov   cx,768
  671. @@:     cmp   BYTE PTR ds:[si],0     ; black ?????
  672.         jne   hahu
  673.         dec   BYTE PTR ds:[si]
  674.         xor   al,al                  ; false !!!
  675. hahu:   inc   si
  676.         dec   cx
  677.         jnz   @B
  678.  
  679.         MPOP  cx,si,ds
  680.  
  681.         leave
  682.         retf
  683.  
  684. _FadeOut ENDP
  685.  
  686. ALIGN
  687. EVEN
  688. _InFade PROC FAR                     ; White to Pal
  689.  
  690. ; ss:[BP+6] = OFFSET Pal
  691. ; ss:[BP+8] = SEG Pal
  692. ; ss:[BP+10] = OFFSET Dest           ; supposed to be white at the beginning !!
  693. ; ss:[BP+12] = SEG Dest
  694.  
  695.  
  696.         push bp
  697.         mov  bp,sp
  698.  
  699.         MPUSH cx,si,di,ds,es         ; AX = result
  700.  
  701.         mov   ax,ss:[BP+8]
  702.         mov   ds,ax
  703.         mov   ax,ss:[BP+12]
  704.         mov   es,ax
  705.  
  706.         mov   si,ss:[BP+6]
  707.         mov   di,ss:[BP+10]
  708.         mov   ah,1                   ; true by default
  709.  
  710.         mov   cx,768
  711. @@:     lodsb
  712.         cmp   al,BYTE PTR es:[di]    ; have we reach the col ???
  713.         jbe   huha
  714.         dec   BYTE PTR es:[di]
  715.         xor   ah,ah                  ; false !!!
  716. huha:   inc   di
  717.         dec   cx
  718.         jnz   @B
  719.         xor   al,al
  720.  
  721.         MPOP  cx,si,di,ds,es
  722.  
  723.         leave
  724.         retf
  725.  
  726. _InFade ENDP
  727.  
  728. ALIGN
  729. EVEN
  730. _OutFade PROC FAR                     ; Pal to White
  731.  
  732. ; ss:[BP+6] = OFFSET Pal
  733. ; ss:[BP+8] = SEG Pal
  734.  
  735.         push bp
  736.         mov  bp,sp
  737.  
  738.         MPUSH cx,si,ds                ; AX = result
  739.  
  740.         mov   ax,ss:[BP+8]
  741.         mov   ds,ax
  742.  
  743.         mov   si,ss:[BP+6]
  744.         mov   ax,1                    ; true by default
  745.  
  746.         mov   cx,768
  747. @@:     cmp   BYTE PTR ds:[si],63     ; white ?????
  748.         jne   hahu
  749.         inc   BYTE PTR ds:[si]
  750.         xor   al,al                   ; false !!!
  751. hahu:   inc   si
  752.         dec   cx
  753.         jnz   @B
  754.  
  755.         MPOP  cx,si,ds
  756.  
  757.         leave
  758.         retf
  759.  
  760. _OutFade ENDP
  761.  
  762. ^
  763.  
  764. _TEXT ENDS
  765.  
  766.       END
  767.